package com.example.justextends;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

public class MainActivity extends Activity {

    private Button addButton(String text, View.OnClickListener l){
        Button b = new Button(this);
        b.setText(text);
        b.setOnClickListener(l);
        return b;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.i("JavaTweak", "OnCreate");

        LinearLayout root = new LinearLayout(this);
        root.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
        root.setOrientation(LinearLayout.VERTICAL);
        setContentView(root);

        root.addView(addButton("splash", v -> changeView((Button) v)));
    }

    public void changeView(Button v){
        v.setText(getValue());
    }

    private String getValue(){
        return "originvalue";
    }

    @Override
    protected void onResume() {
        Log.i("JavaTweak", "onResume");
        super.onResume();
    }
}